home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWArcShp.h next >
Encoding:
Text File  |  1994-04-21  |  4.7 KB  |  171 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWArcShp.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWARCSHP_H
  13. #define FWARCSHP_H
  14.  
  15. // ----- Foundation Includes -----
  16.  
  17. #ifndef FWSTDDEF_H
  18. #include <FWStdDef.h>
  19. #endif
  20.  
  21. #ifndef FWSHAPE_H
  22. #include "FWShape.h"
  23. #endif
  24.  
  25. #ifndef FWBNDSHP_H
  26. #include "FWBndShp.h"
  27. #endif
  28.  
  29. #ifndef FWINK_H
  30. #include "FWInk.h"
  31. #endif
  32.  
  33. #ifndef FWSTYLE_H
  34. #include "FWStyle.h"
  35. #endif
  36.  
  37. //========================================================================================
  38. //    •• Forward Declarations
  39. //========================================================================================
  40.  
  41. class FW_CGraphicContext;
  42. class FW_CArcShapeRep;
  43. class FW_COvalShape;
  44. class FW_CRoundRectShape;
  45. class FW_CRectShape;
  46. class FW_CLineShape;
  47. class FW_CRegionShape;
  48.  
  49. //========================================================================================
  50. //    •• CLASS FW_CArcShape
  51. //========================================================================================
  52.  
  53. class FW_CArcShape : public FW_CShape
  54. {
  55. //----------------------------------------------------------------------------------------
  56. //    • Constructors
  57. //
  58. public:
  59.     FW_CArcShape();
  60.     FW_CArcShape(const FW_CRect& rect, short startAngle, short arcAngle);
  61.     
  62.     FW_CArcShape(const FW_CArcShape& other);
  63.     FW_CArcShape(FW_CArcShapeRep* rep);
  64.             
  65. //----------------------------------------------------------------------------------------
  66. //    • Operators
  67. //
  68. public:
  69.     FW_CArcShape& operator=(const FW_CArcShape& other);
  70.     FW_CArcShape& operator=(FW_CArcShapeRep* other);
  71.     FW_CArcShapeRep* operator->() const
  72.                 {return (FW_CArcShapeRep*)GetRep();}
  73.  
  74. //----------------------------------------------------------------------------------------
  75. //    • Conversion
  76. //
  77. public:
  78.     operator FW_COvalShape() const;
  79.     operator FW_CRoundRectShape() const;
  80.     operator FW_CRectShape() const;
  81.     operator FW_CLineShape() const;
  82.     operator FW_CRegionShape() const;
  83.  
  84. //----------------------------------------------------------------------------------------
  85. //    • Static Methods
  86. //
  87. public:
  88.     static void DrawArc(FW_CGraphicContext* graphicContext,
  89.                             const FW_CRect& rect, 
  90.                             short startAngle, 
  91.                             short arcAngle);
  92. };
  93.  
  94. //========================================================================================
  95. //    •• class FW_CArcShapeRep
  96. //========================================================================================
  97.  
  98. class FW_CArcShapeRep : public FW_CBoundedShapeRep
  99. {
  100.     friend class FW_CArcShape;
  101.     
  102. //----------------------------------------------------------------------------------------
  103. //    • Constructors/Destructors
  104. //
  105. protected:
  106.     FW_CArcShapeRep();
  107.     FW_CArcShapeRep(const FW_CRect& rect, short startAngle, short arcAngle);
  108.     
  109.     virtual ~FW_CArcShapeRep();
  110.     
  111. //----------------------------------------------------------------------------------------
  112. //    • Inherited API
  113. //
  114. public:
  115.     // ----- Rendering -----
  116.     virtual void     Draw(FW_CGraphicContext* graphicContext);
  117.     static void     DrawArc(FW_CGraphicContext* graphicContext,
  118.                             const FW_CRect& rect, 
  119.                             short startAngle, 
  120.                             short arcAngle);
  121.     
  122.     // ----- Hit Testing -----
  123.     virtual FW_HitTestPart HitTest(const FW_CPoint& test) const;
  124.  
  125.     // ----- Default shape -----
  126.     virtual void     SetAsDefault() const;
  127.  
  128.     // ----- Stream -----
  129.     virtual void    Flatten(FW_CWritableStream& stream);
  130.     virtual void    Unflatten(FW_CReadableStream& stream);
  131.  
  132. //----------------------------------------------------------------------------------------
  133. //    • New API
  134. //
  135. public:
  136.     FW_CArcShape    Copy() const;
  137.  
  138.     short            GetStartAngle() const
  139.                         {return fStartAngle;}    
  140.     void            SetStartAngle(short angle)
  141.                         {fStartAngle = angle; Changed();}
  142.     
  143.     short            GetArcAngle() const
  144.                         {return fArcAngle;}    
  145.     void            SetArcAngle(short angle)
  146.                         {fArcAngle = angle; Changed();}
  147.  
  148. //----------------------------------------------------------------------------------------
  149. //    • Data Members
  150. //
  151. private:
  152.     short            fStartAngle;    
  153.     short            fArcAngle;
  154. };
  155.  
  156. //========================================================================================
  157. //    •• Inlines
  158. //========================================================================================
  159.  
  160. //----------------------------------------------------------------------------------------
  161. //    • FW_CArcShape::DrawArc
  162. //----------------------------------------------------------------------------------------
  163. inline static void FW_CArcShape::DrawArc(FW_CGraphicContext* graphicContext,
  164.                                             const FW_CRect& rect, 
  165.                                             short startAngle, 
  166.                                             short arcAngle)
  167. {
  168.     FW_CArcShapeRep::DrawArc(graphicContext, rect, startAngle, arcAngle);
  169. }
  170.  
  171. #endif